
{extend name='admin@main'}

{block name="content"}
{include file='backstage@announcement/form-style'}

<form class="layui-form layui-card" id="Form" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
    <div class="layui-card-body padding-left-40">
        <div class="layui-form-item">
            <label class="relative block">
                <span class="color-green font-w7">标题</span>
                <span class="color-desc margin-left-5">Title</span>
                <input name="title" value='{$vo.title|default=""}' required pattern="^.{2,}$" placeholder="请输入公告标题" class="layui-input">
            </label>
        </div>

        <div class="layui-form-item label-required-prev">
            <span class="color-green">公告内容</span>
            <textarea name='content'>{$vo.content|raw|default=""}</textarea>
        </div>
    </div>

    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center" style="padding: 0 0 15px;">
        {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
        <button class="layui-btn" type="submit">保存</button>
        <button class="layui-btn layui-btn-danger" ng-click="historyBack()" type="button">返回</button>
    </div>

</form>

{/block}
{block name='script'}
<script>
    window.form.render();
    require(['ckeditor', 'angular'], function () {
        var editor = window.createEditor('[name="content"]',{
            height: 400
        });
        var app = angular.module("Form", []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);
        function callback($rootScope) {
            $rootScope.historyBack = function () {
                $.msg.confirm('确定要取消编辑吗？', function (index) {
                    history.back(), $.msg.close(index);
                });
            };
        }


    });
</script>
{/block}
